﻿namespace Pub.Class
{
    using System;
    using System.IO;
    using System.Web;

    public class Server2
    {
        public static string GetMapPath(string strPath)
        {
            if (HttpContext.Current.IsNotNull())
            {
                return HttpContext.Current.Server.MapPath(strPath);
            }
            strPath = strPath.Replace("/", @"\");
            if (strPath.StartsWith(@".\"))
            {
                strPath = strPath.Substring(2);
            }
            strPath = strPath.TrimStart(new char[] { '~' }).TrimStart(new char[] { '\\' });
            return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);
        }
    }
}

